<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #box{
            width: 3rem;
            height: 1rem;
            border:solid 1px #000;
            margin: 1rem auto;
        }
        #box2{
            width: 3rem;
            height: 1rem;
            border:solid 0.01rem #000;
            margin: 1rem auto;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <div class="gap"></div>
    <div id="box2"></div>
    <script>
        let s = 100 * document.documentElement.clientWidth / 375;//  100  => 200
        document.documentElement.style.fontSize = s + 'px';

        //修改 meta 标签
        let viewport = document.querySelector('meta[name=viewport]');
        //修改 meta 中 content 属性的值
        viewport.content = 'initial-scale=' + 1/window.devicePixelRatio   //  

        let newFont = s * window.devicePixelRatio;
        document.documentElement.style.fontSize = newFont + 'px';
    </script>
</body>
</html>